Release 10.1A: OpenEdge Development:
ProDataSets
Data access procedure example
Let’s write a very simple support procedure to handle the data access for one new ProDataSet. You’ll use this ProDataSet in other examples in this chapter.
To show something different from
Orders andOrderLines, and to provide a basis for data caching and data sharing between procedures, the sample ProDataSet is a set of independent tables that have coded values of one kind or another. Within the limited confines of the Sports2000 database, likely candidates are theStatetable, theDepartmenttable, and theSalesReptable. These are all limited enough in scope that the tables can be completely populated when the ProDataSet is first filled.Here is the
dsCodeTT.iinclude file, with the temp-table definitions:
You can see that the
ttSalesReptable is different from the database table it’s derived from. It maps some database fields to different names in the temp-table and generates two calculated fields as well.Here is the
dsCode.iinclude file with the ProDataSet definition:
This couldn’t be any simpler. There are no relationships between the tables, so the ProDataSet definition only needs to list them.
Now let’s start to build the data access support procedure that defines the Data-Sources and handles the
FILLlogic. First, it defines the Data-Sources, which are also quite simple, as each one names just a single database table the ProDataSet temp-table is derived from. Thus, there’s no need for query definitions. Progress can generate the queries it needs for loading data automatically, as shown:
The other thing to note about the top of the procedure is that it doesn’t include the temp-table or ProDataSet definitions. The ProDataSet is always referenced by its handle alone, which means that anything about the ProDataSet definition can change without requiring even a recompile of this procedure. The only dependencies are the specific fields that the procedures must map or reference for calculations. Even in those cases, the code that maps or references them could be made conditional so that it would not fail if the fields were removed from the ProDataSet, or this procedure was used with a version of the ProDataSet that didn’t have them.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |